<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class C_mainpage extends MY_Controller {

    public function __construct() {
        parent::__construct();
        $this->lang->load('static', $this->current_lang);
    }

    public function index() {
        $this->view->setTitle(lang('static_main_title'));
        $this->view->setGlobal('head', $this->load->view('v_head', '', true));
        $this->view->setGlobal('content', $this->load->view('pages/v_mainpage', '', true));
        $this->view->render();
    }

    public function about() {
        $this->view->setTitle(lang('static_about_title'));
        $this->view->setGlobal('head', $this->load->view('v_head', '', true));
        $this->view->setGlobal('content', $this->load->view('/pages/v_about', '', true));
        $this->view->render();
    }

    public function feedback() {
        $this->load->library(array('form_validation', 'email'));
        $this->load->helper('form');
        $this->lang->load('form_validation', $this->current_lang);
        $this->view->setTitle(lang('static_feedback_title'));
        $this->view->setGlobal('head', $this->load->view('v_head', '', true));
        $this->form_validation->set_rules('name', lang('static_feedback_yourname'), 'trim|required|min_length[3]|xss_clean');
        $this->form_validation->set_rules('email', lang('static_feedback_email'), 'trim|required|valid_email');
        $this->form_validation->set_rules('subject', lang('static_feedback_topic'), 'trim|required|min_length[3]');
        $this->form_validation->set_rules('text', lang('static_feedback_message'), 'trim|required|min_length[3]');
        $this->form_validation->set_error_delimiters('<div class="error">', '</div>');

        if ($this->form_validation->run() == FALSE) {
            $this->view->setGlobal('content', $this->load->view('feedback/v_form', '', true));
        } else {
            $config['mailtype'] = 'html';
            $this->email->initialize($config);
            $this->email->from($this->input->post('email'), $this->input->post('name'));
            $this->email->to('allejik@gdia.sf');
            $this->email->subject($this->input->post('subject'));
            $this->email->message($this->input->post('text'));
            if (!$this->email->send()) {
                $data['message'] = lang('static_feedback_msgError');
            } else {
                $data['message'] = lang('static_feedback_msgOk');
            }
            $this->view->setGlobal('content', $this->load->view('feedback/v_status', $data, true));
        }

        $this->view->render();
    }

    public function help() {

        $this->view->setTitle(lang('static_help_title'));
        $this->view->setGlobal('head', $this->load->view('v_head', '', true));
        $this->view->setGlobal('content', $this->load->view('/pages/v_instruction', '', true));

        $this->view->render();
    }

    public function journal() {
        $this->view->setTitle(lang('nav_journal'));
        $data['journal_tabs'] = $this->load->view('journal/v_journal_tabs', '', true);
        $this->view->setGlobal('head', $this->load->view('v_head', $data, true));
        $this->view->setGlobal('content', $this->load->view('journal/v_journal', '', true));
        $this->view->render();
    }

}

/* End of file c_mainpage.php */
/* Location: ./application/controllers/c_mainpage.php */